package com.yamanyar.weebill.dao;

import java.io.Serializable;
import java.util.List;

/**
 * GenericDAO expects to be extended by entity specific data access object.
 * 
 * Created in Jun 22, 2008.
 * 
 * @author Kaan Yamanyar
 * @param <T>
 *            Type of Entity.
 * @param <ID>
 *            Type of ID.
 */
public interface GenericDAO<T, ID extends Serializable> {

	/**
	 * Loads an entity by it's id.
	 * 
	 * @param id
	 * @return entity
	 */
	T loadById(ID id);

	/**
	 * stores an entity.
	 * 
	 * @param entity
	 */
	void persist(T entity);

	/**
	 * updates an entity which is already saved.
	 * 
	 * @param entity
	 */
	void update(T entity);

	/**
	 * removes an entity from database.
	 * 
	 * @param entity
	 */
	void delete(T entity);

	/**
	 * return all the entities of that specific type.
	 * 
	 * @return list of entities.
	 */
	List<T> loadAll();

}
